<template>
  <div>
    <h1>登录</h1>
    <van-form @submit="onSubmit">
      <van-field
          v-model="form.username"
          name="用户名"
          label="用户名"
          placeholder="用户名"
          :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
          v-model="form.password"
          type="password"
          name="密码"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">提交</van-button>
      </div>
    </van-form>


  </div>
</template>

<script>
import myaxios from "@/http/axios";

export default {
  name: "slogin",
  data() {
    return {
      data1: '',
      form:{}
    }
  },
  methods: {
    onSubmit() {
      myaxios('slogin','post',this.form).then(res=>{
        localStorage.setItem('userid',res.userid)
        localStorage.setItem('is_admin',res.is_admin)
        if (res.is_admin==1){
          this.$router.push('is_caozuo')
        }else {
          this.$router.push('admin_caozuo')
        }
      })
    },
  },
  mounted() {

  }
}
</script>

<style scoped>

</style>